package com.burgeon.backend.SHOPBACKEND.controller;
/**
 * 秒杀产品
 */
import com.burgeon.backend.SHOPBACKEND.entity.Seckill;
import com.burgeon.backend.SHOPBACKEND.service.BackendSeckillService;
import com.burgeon.backend.stsutil.ResponseResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;

@RestController
@CrossOrigin
@RequestMapping("shop/seckill")
public class BackendSeckillController extends BaseController {
    @Autowired
    private BackendSeckillService backendSeckillService;

    @RequestMapping("putaway")
    public ResponseResult<Void> putawayData(String id,String yn) {
        backendSeckillService.putaway(id,yn);
        return new ResponseResult<>(SUCCESS);
    }

    @RequestMapping("data")
    public ResponseResult<List<Seckill>> getData(String account) {
        List<Seckill> data = backendSeckillService.getData(account);
        return new ResponseResult<List<Seckill>>(SUCCESS,data);
    }


    @RequestMapping("delDatches")
    public ResponseResult<Void> delDatches(String[] ids) {
        for (String id:ids){
            backendSeckillService.delData(id);
        }

        return new ResponseResult<>(SUCCESS);
    }


    @RequestMapping("del")
    public ResponseResult<Void> delData(String id) {
        backendSeckillService.delData(id);
        return new ResponseResult<>(SUCCESS);
    }

    @RequestMapping("create")
    public ResponseResult<Void> addData(String code,String putaway,String price,String endTime, String account) {
        backendSeckillService.addSeckill(code,putaway,price,endTime,account);
        return new ResponseResult<>(SUCCESS);
    }

}
